<?php
require_once 'config.php';
//生成唯一的游客ID；
function cid()
{
    return md5(uniqid());
}

//调用api接口方法
function getCurl($url, $post_data, $method = 'get')
{
    $post_data = http_build_query($post_data);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if ($method != 'get') {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    }
//    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

function getParam($arr, $key, $default = '')
{
    if (isset($arr[$key])) {
        $default = $arr[$key];
    }
    return $default;

}

////检查是否游客登录状态
//function checkLogin()
//{
//    if (!isset($_SESSION['num']) && !(getParam($_SESSION, 'num') != null)) {
//        echo "<script language='javascript' type="text/javascript\">alert('不是游客登录状态');</script>
//        <script language='javascript' type="text/javascript">location.href='login.php';</script>";
//
//    }
//}
